<?php

class Vlib_Module_Config {

    /**------------------------------------------------------------------------------------
     * @desc Get module config array
     * 
     * @author Tuyendn <tuyendn@vnext.vn>
     *------------------------------------------------------------------------------------*/
    public static function getConfig($_module = '') {
        if (empty($_module)) {
            $_request = new Zend_Controller_Request_Http();
            $_module = $_request->getModuleName();
        }
        $_moduleDir = Vlib_Module_Loader::getIntance()->getModuleDir();
        // only support ini config file
        $_configFile = $_moduleDir . DS . $_module . DS . 'config' . DS . 'config.php';
        if (!file_exists($_configFile)) {
            return array();
        }
        $_config = include $_configFile;
        
        return $_config;
    }
    
    /**------------------------------------------------------------------------------------
     * @desc Get config from database
     * 
     * @author Tuyendn <tuyendn@vnext.vn>
     *------------------------------------------------------------------------------------*/
    public static function getDbConfig($_module = '') {
        if (empty($_module)) {
            $_request = new Zend_Controller_Request_Http();
            $_module = $_request->getModuleName();
        }
        
        $_logic = new Vlib_Models_Table();
        
        return $_logic->getDbConfig($_module);
    }
}